package com.example.demo.network;

import com.xiaoleilu.hutool.http.Header;
import com.xiaoleilu.hutool.http.HttpRequest;
import com.xiaoleilu.hutool.json.JSON;
import com.xiaoleilu.hutool.json.JSONArray;
import com.xiaoleilu.hutool.json.JSONObject;
import com.xiaoleilu.hutool.json.JSONUtil;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class TestHttp {

    public static void main(String[] args) {

        String url = "http://192.168.1.87:7020/v1/retrieval/indexes";
        Map<String, Object> map = new HashMap<>();
        map.put("indexName", "test000");
        map.put("indexStoreType", "FLAT");
        map.put("indexType", "FACE");
        JSON parse = JSONUtil.parse(map);
        String result = HttpRequest.post(url)
                .header(Header.CONTENT_TYPE, "application/json;charset=utf-8")//头信息，多个头信息多次调用此方法即可
                .body(parse)//表单内容
                .timeout(20000)//超时，毫秒
                .execute().body();

        System.out.println(result);

    }
}
